﻿using Microsoft.EntityFrameworkCore;
using QuartzServices.Domain.Interfaces;
using QuartzServices.Domain.DomainModels;

namespace QuartzServices.Infrastructure.Repository
{
    public class JabilApiTokenRepository : Repository<JabilApiTokenModel>, IJabilApiTokenRepository
    {

        public JabilApiTokenRepository(MainDBContext mainDBContext) : base(mainDBContext) { }

        /// <summary>
        /// 获取最新的Token
        /// </summary>
        /// <returns></returns>
        public async Task<JabilApiTokenModel?> GetLatest()
        {
            return await _dbContext.JabilApiTokens.OrderByDescending(d => d.Modifiedon).FirstOrDefaultAsync();

        }
    }
}
